package IO流.image;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class 黑白 {
    public static void main(String[] args) throws Exception {
        //读取图像
       var src= ImageIO.read(new File("e:/yk.jpg"));
      var h=src.getHeight();
      var w=src.getWidth();
      //10为灰白
      var i=new BufferedImage(w,h,10);
      //设置画笔
      var g=i.createGraphics();
      //是用画笔将src图像画成黑白图像
      g.drawImage(src,0,0,null);



      g.dispose();
      ImageIO.write(i,"jpg",new File("e:/yk1.jpg"));
        Runtime.getRuntime().exec("cmd /k start e:/yk1.jpg");
    }
}
